/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TweetRay.Backgrounds;

import Raytracing.Constants;
import processing.core.PVector;

/**
 *
 * @author Matt
 */
public class GradientBackground extends Background {

    
    float hard = 1.5f;
    
    public void getColor(PVector dir, PVector ret) {

        PVector toSun = new PVector(1,-1f,1f);
        toSun.normalize();

        dir.normalize();
        
        float ang = (float)Math.acos(toSun.dot(dir));
       
        //scale to range 0-1
        ang /= Constants.PI;
        
        //invert
        ang = 1.f - ang;

               
        ang=(float)Math.pow(ang,hard);
        
        ret.set(ang,ang,ang);


    }
}
